﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MySite.master" Title="Catalogs" CodeBehind="CargoForm.aspx.cs" EnableEventValidation="false" Inherits="DigDes.DSchool.SUPS.WebApp.CargoForm" %>

<asp:Content ID="Cargo" ContentPlaceHolderID="Main" runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
        <ContentTemplate>
            <asp:GridView
                ID="GridView1"
                runat="server"
                AllowPaging="True"
                AutoGenerateColumns="False"
                CssClass="grid"
                GridLines="Horizontal"
                CellPadding="5"
                PageSize="5"
                DataKeyNames="Cargo_ID"
                OnSelectedIndexChanged="OnSelectedIndexChanged"
                OnPageIndexChanged="Page_Load"
                OnRowDataBound="OnRowDataBound"
                SelectedIndex="-1"
                DataSourceID="CargoObjectDataSource" BorderStyle="None">

                <Columns>
                    <asp:BoundField DataField="Cargo_ID" HeaderText="Cargo_ID" SortExpression="Cargo_ID" Visible="false" />
                    <asp:BoundField DataField="Name" HeaderText="Груз" SortExpression="Name" />
                    <asp:BoundField DataField="Description" HeaderText="Описание груза" SortExpression="Description" />
                    <asp:BoundField DataField="ShortCode" HeaderText="Краткий код" SortExpression="ShortCode" />
                    <asp:BoundField DataField="Code" HeaderText="Код" SortExpression="Code" />
                    <asp:BoundField DataField="CodeGNG" HeaderText="Код груза в CNG" SortExpression="CodeGNG" />
                    <asp:BoundField DataField="Mnemocode" HeaderText="Мнемокод" SortExpression="Mnemocode" />
                    <asp:CheckBoxField DataField="IsUsed" HeaderText="Используется" SortExpression="IsUsed" />
                    <asp:CheckBoxField DataField="IsEmpty" HeaderText="Порожний" SortExpression="IsEmpty" />
                    <asp:TemplateField HeaderText="Изображение">
                        <ItemTemplate>
                            <asp:Image Height ="40px"
                                ID="Image1" 
                                runat="server"
                                ImageUrl='<%# "~/CargoFormImage.ashx?Cargo_ID=" + Eval("Cargo_ID")%>'/>
                         </ItemTemplate>
                     </asp:TemplateField>
                  </Columns>

                <HeaderStyle CssClass="grid-header" />
                <RowStyle CssClass="grid-row" />
                <SelectedRowStyle CssClass="grid-selected-row" />
                <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Center" BorderStyle="None" />

            </asp:GridView>

            <br />

            <asp:Button ID="Add_Button" runat="server" Text="Добавить" OnClick="Add_Button_Click" CssClass="button" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button ID="Edit_Button" runat="server" Text="Редактировать" OnClick="Edit_Button_Click" Visible=" false" CssClass="button" Width="150px" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button ID="Delete_Button" runat="server" Text="Удалить" OnClick="Delete_Button_Click" Visible="false" CssClass="button" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <br />

            <br />
            <asp:Label ID="DVNameLabel" runat="server" Text="" ForeColor="#5684A3" Font-Size="15"></asp:Label>


            <asp:FormView runat="server" ID="RowDetails" DataSourceID="DetailsObjectDataSource" Visible="false" Width="284px">
                <ItemTemplate>
                    <asp:TextBox Text='<%# Bind("Cargo_ID") %>' runat="server" ID="Cargo_ID" CssClass="textbox" Visible="false" /><br />

                    <asp:Label ID="Name_Label" runat="server" Text="Груз" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("Name") %>' runat="server" ID="Name_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="Description_Label" runat="server" Text="Описание груза" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("Description") %>' runat="server" ID="Description_TextBox" CssClass="description" Height="50px" Width="300px" TextMode="MultiLine" /><br />
                    <br />

                    <asp:Label ID="DescriptionEng_Label" runat="server" Text="Описание(англ)" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("DescriptionEng") %>' runat="server" ID="DescriptionEng_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="ShortCode_Label" runat="server" Text="Код в ESTNG" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("ShortCode") %>' runat="server" ID="ShortCode_TextBox" CssClass="textbox" Width="60px" /><br />
                    <br />

                    <asp:Label ID="Code_Label" runat="server" Text="Код груза" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("Code") %>' runat="server" ID="Code_TextBox" CssClass="textbox" Width="60px" /><br />
                    <br />

                    <asp:Label ID="CodeGNG_Label" runat="server" Text="Код груза в GNG" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("CodeGNG") %>' runat="server" ID="CodeGNG_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="Mnemocode_Label" runat="server" Text="Мнемокод груза" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("Mnemocode") %>' runat="server" ID="Mnemocode_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="MnemocodeEng_Label" runat="server" Text="Мнемокод(англ)" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("MnemocodeEng") %>' runat="server" ID="MnemocodeEng_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="IsUsed_Label" runat="server" Text="Используется" CssClass="textbox-label"></asp:Label><br />
                    <asp:CheckBox Checked='<%# Bind("IsUsed") %>' runat="server" ID="IsUsed_CheckBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="IsEmpty_Label" runat="server" Text="Порожний" CssClass="textbox-label"></asp:Label><br />
                    <asp:CheckBox Checked='<%# Bind("IsEmpty") %>' runat="server" ID="IsEmpty_CheckBox" CssClass="textbox" /><br />

                </ItemTemplate>

                <EditItemTemplate>
                    <asp:TextBox Text='<%# Bind("Cargo_ID") %>' runat="server" ID="Cargo_ID" CssClass="textbox" Visible="false" /><br />

                    <asp:Label ID="Name_Label" runat="server" Text="Груз" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("Name") %>' runat="server" ID="Name_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="Description_Label" runat="server" Text="Описание груза" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("Description") %>' runat="server" ID="Description_TextBox" CssClass="description" Height="50px" Width="300px" TextMode="MultiLine" /><br />
                    <br />

                    <asp:Label ID="DescriptionEng_Label" runat="server" Text="Описание(англ)" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("DescriptionEng") %>' runat="server" ID="DescriptionEng_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="ShortCode_Label" runat="server" Text="Код в ESTNG" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("ShortCode") %>' runat="server" ID="ShortCode_TextBox" CssClass="textbox" Width="60px" /><br />
                    <br />

                    <asp:Label ID="Code_Label" runat="server" Text="Код груза" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("Code") %>' runat="server" ID="Code_TextBox" CssClass="textbox" Width="60px" /><br />
                    <br />

                    <asp:Label ID="CodeGNG_Label" runat="server" Text="Код груза в GNG" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("CodeGNG") %>' runat="server" ID="CodeGNG_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="Mnemocode_Label" runat="server" Text="Мнемокод груза" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("Mnemocode") %>' runat="server" ID="Mnemocode_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="MnemocodeEng_Label" runat="server" Text="Мнемокод(англ)" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("MnemocodeEng") %>' runat="server" ID="MnemocodeEng_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="IsUsed_Label" runat="server" Text="Используется" CssClass="textbox-label"></asp:Label><br />
                    <asp:CheckBox Checked='<%# Bind("IsUsed") %>' runat="server" ID="IsUsed_CheckBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="IsEmpty_Label" runat="server" Text="Порожний" CssClass="textbox-label"></asp:Label><br />
                    <asp:CheckBox Checked='<%# Bind("IsEmpty") %>' runat="server" ID="IsEmpty_CheckBox" CssClass="textbox" /><br />

                </EditItemTemplate>

                <InsertItemTemplate>
                    <asp:Label ID="Name_Label" runat="server" Text="Груз" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("Name") %>' runat="server" ID="Name_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="Description_Label" runat="server" Text="Описание груза" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("Description") %>' runat="server" ID="Description_TextBox" CssClass="description" Height="50px" Width="300px" TextMode="MultiLine" /><br />
                    <br />

                    <asp:Label ID="DescriptionEng_Label" runat="server" Text="Описание(англ)" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("DescriptionEng") %>' runat="server" ID="DescriptionEng_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="ShortCode_Label" runat="server" Text="Код в ESTNG" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("ShortCode") %>' runat="server" ID="ShortCode_TextBox" CssClass="textbox" Width="60px" /><br />
                    <br />

                    <asp:Label ID="Code_Label" runat="server" Text="Код груза" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("Code") %>' runat="server" ID="Code_TextBox" CssClass="textbox" Width="60px" /><br />
                    <br />

                    <asp:Label ID="CodeGNG_Label" runat="server" Text="Код груза в GNG" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("CodeGNG") %>' runat="server" ID="CodeGNG_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="Mnemocode_Label" runat="server" Text="Мнемокод груза" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("Mnemocode") %>' runat="server" ID="Mnemocode_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="MnemocodeEng_Label" runat="server" Text="Мнемокод(англ)" CssClass="textbox-label"></asp:Label><br />
                    <asp:TextBox Text='<%# Bind("MnemocodeEng") %>' runat="server" ID="MnemocodeEng_TextBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="IsUsed_Label" runat="server" Text="Используется" CssClass="textbox-label"></asp:Label><br />
                    <asp:CheckBox Checked='<%# Bind("IsUsed") %>' runat="server" ID="IsUsed_CheckBox" CssClass="textbox" /><br />
                    <br />

                    <asp:Label ID="IsEmpty_Label" runat="server" Text="Порожний" CssClass="textbox-label"></asp:Label><br />
                    <asp:CheckBox Checked='<%# Bind("IsEmpty") %>' runat="server" ID="IsEmpty_CheckBox" CssClass="textbox" /><br />

                </InsertItemTemplate>

            </asp:FormView>


            <asp:Button ID="Save_Button" runat="server" Text="Сохранить" Visible="false" OnClick="Save_Button_Click" CssClass="save-button" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
    <asp:Button ID="Cancel_Button" runat="server" Text="Отмена" Visible="false" OnClick="Cancel_Button_Click" CssClass="button" />
            <br />
        </ContentTemplate>

        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Add_Button" EventName="Click" />

            <asp:AsyncPostBackTrigger ControlID="Edit_Button" EventName="Click" />

            <asp:AsyncPostBackTrigger ControlID="Delete_Button" EventName="Click" />

            <asp:AsyncPostBackTrigger ControlID="Save_Button" EventName="Click" />

            <asp:AsyncPostBackTrigger ControlID="Cancel_Button" EventName="Click" />
        </Triggers>

    </asp:UpdatePanel>

    <asp:FileUpload ID="Image_Upload" runat="server" CssClass="button" Visible="true" Width="150px" />
    &nbsp;&nbsp;&nbsp;
    <asp:Button ID="Load_Button" runat="server" Text="Загрузить" OnClick="Load_Button_Click" Visible="true" CssClass="button" /><br />

    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:ObjectDataSource
                ID="CargoObjectDataSource"
                runat="server"
                TypeName="DigDes.DSchool.SUPS.DataAccess.Database.CargoWebFormLoader"
                DeleteMethod="DeleteSelectedCargo"
                SelectMethod="SelectCargoPaged"
                SelectCountMethod="TotalNumberOfСargos"
                MaximumRowsParameterName="PageSize"
                StartRowIndexParameterName="startRowIndex"
                EnablePaging="True">

                <DeleteParameters>
                    <asp:Parameter Name="Cargo_ID" Type="String" />
                </DeleteParameters>

            </asp:ObjectDataSource>

    <asp:ObjectDataSource ID="DetailsObjectDataSource" runat="server"
        InsertMethod="InsertCargo"
        SelectMethod="GetSelectedCargo"
        TypeName="DigDes.DSchool.SUPS.DataAccess.Database.CargoWebFormLoader"
        UpdateMethod="UpdateSelectedCargo">

        <InsertParameters>
            <asp:Parameter Name="Name" Type="String" DefaultValue="Пустой" />
            <asp:Parameter Name="NameEng" Type="String" DefaultValue=" " />
            <asp:Parameter Name="Description" Type="String" DefaultValue=" " />
            <asp:Parameter Name="DescriptionEng" Type="String" DefaultValue=" " />
            <asp:Parameter Name="ShortCode" Type="String" DefaultValue=" " />
            <asp:Parameter Name="Code" Type="String" DefaultValue=" " />
            <asp:Parameter Name="CodeGNG" Type="String" DefaultValue=" " />
            <asp:Parameter Name="Mnemocode" Type="String" DefaultValue=" " />
            <asp:Parameter Name="MnemocodeEng" Type="String" DefaultValue=" " />
            <asp:Parameter Name="IsUsed" Type="Boolean" DefaultValue="false" />
            <asp:Parameter Name="IsEmpty" Type="Boolean" DefaultValue="true" />
        </InsertParameters>

        <SelectParameters>
            <asp:ControlParameter
                ControlID="GridView1"
                DefaultValue="1"
                Name="Cargo_ID"
                PropertyName="SelectedValue"
                Type="String" />
        </SelectParameters>

        <UpdateParameters>
            <asp:Parameter Name="Cargo_ID" Type="String" />
            <asp:Parameter Name="Name" Type="String" DefaultValue=" " />
            <asp:Parameter Name="NameEng" Type="String" DefaultValue=" " />
            <asp:Parameter Name="Description" Type="String" DefaultValue=" " />
            <asp:Parameter Name="DescriptionEng" Type="String" DefaultValue=" " />
            <asp:Parameter Name="ShortCode" Type="String" DefaultValue=" " />
            <asp:Parameter Name="Code" Type="String" DefaultValue=" " />
            <asp:Parameter Name="CodeGNG" Type="String" DefaultValue=" " />
            <asp:Parameter Name="Mnemocode" Type="String" DefaultValue=" " />
            <asp:Parameter Name="MnemocodeEng" Type="String" />
            <asp:Parameter Name="IsUsed" Type="Boolean" DefaultValue="false" />
            <asp:Parameter Name="IsEmpty" Type="Boolean" DefaultValue="true" />
        </UpdateParameters>
    </asp:ObjectDataSource>

</asp:Content>
